import time

from zhokao3.Base import Base
from selenium.webdriver.common.by import By
class Page(Base):
    wz='http://10.59.9.12:7001/home/login.html'
    zh=(By.NAME,'username')
    mm=(By.NAME,'password')
    dl=(By.XPATH,'//*[@id="theForm"]/div[5]/a')
    sy=(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a')
    sp=(By.XPATH,'/html/body/div[8]/div[1]/div[2]/div[2]/ul/li[2]/div[1]/a/img')
    jr=(By.XPATH,'//*[@id="add-cart"]')
    gwc=(By.XPATH,'/html/body/div[3]/div[3]/div[2]/a')
    xz=(By.XPATH,'//*[@id="cart-box"]/div[1]/table/tbody/tr[2]/td[1]/input')
    js=(By.XPATH,'//*[@id="cartForm"]/div[2]/div/a[2]')
    dz=(By.XPATH,'//*[@id="address-133"]')
    xyb=(By.XPATH,'//*[@id="order-button"]')
    dy1=(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a')
    dy2=(By.CLASS_NAME,'succe-ico')
    def cz(self,zh,mm):
        time.sleep(2)
        self.get_url(self.wz)
        time.sleep(2)
        self.send_keys(self.zh,zh)
        self.send_keys(self.mm,mm)
        #强制等待强制等待时间
        time.sleep(10)
        self.click(self.dl)
        time.sleep(5)
        assert '欢迎回来' in self.test(self.dy1)
        print(self.test(self.dy1))
        time.sleep(5)
        self.click(self.sy)
        time.sleep(2)
        self.click(self.sp)
        time.sleep(2)
        self.click(self.jr)
        time.sleep(2)
        self.click(self.gwc)
        time.sleep(2)
        self.click(self.xz)
        time.sleep(2)
        self.click(self.js)
        time.sleep(2)
        self.click(self.dz)
        time.sleep(2)
        self.click(self.xyb)
        time.sleep(2)
        assert '您的订单支付成功' ==self.test(self.dy2)
        print(self.test(self.dy2))
        time.sleep(2)